import { makeAutoObservable } from 'mobx';
import { injectable } from 'inversify';
import { UserEntity } from './user.entity.ts';

@injectable()
export class UserModel {
  user = new UserEntity();
  private _loading = false;

  get authenticated() {
    return this.user.authenticated;
  }

  set authenticated(value: boolean) {
    this.user.authenticated = value;
  }

  get loading(): boolean {
    return this._loading;
  }

  set loading(value: boolean) {
    this._loading = value;
  }

  constructor() {
    makeAutoObservable(this);
  }

  initialize(param: UserEntity) {
    this.user = new UserEntity(param);
    this.user._initialized = true;
  }

  dispose() {
    this.user = new UserEntity();
  }
}
